import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', {
  state: () => {
    return { count: 3 }

  },
  // 也可以这样定义
  // state: () => ({ count: 0 })
  actions: {
    increment() {
      this.count++
    },
    get(num){
      // this.count = 122 + num
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          this.count = 12212 + num
          resolve(true)
        }, 10)
      })
    }
  },
})
